//
//  SettingTableViewController.m
//  Lovetome
//
//  Created by Xiemaoxiong on 16/7/7.
//  Copyright © 2016年 上海爱途蜜网络科技有限公司. All rights reserved.
//

#import "SettingTableViewController.h"
#import "SettingTableViewCell.h"
#import "FeedbackViewController.h"
#import "AboutUsViewController.h"
#import "MyCollectionViewController.h"
@interface SettingTableViewController ()
@property (nonatomic , strong) NSArray *cellModel;
@end

@implementation SettingTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"更多";
    self.tableView.backgroundColor = Color_BackGroundColor;
    [self.tableView setTableFooterView:[UIView new]];
 
}

#pragma mark - Table view data source

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return ((NSArray *)self.cellModel[section]).count;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.cellModel.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *ID = @"cellid";
        SettingTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
        if (!cell) {
            cell = [[SettingTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:ID];
            [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
        }
        NSDictionary *dict = self.cellModel[indexPath.section][indexPath.row];
        [cell initWithDic:dict];
    
        return cell;
        
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 20;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSDictionary *dict = self.cellModel[indexPath.section][indexPath.row];
    UIViewController *controller = [[dict[@"ViewController"] alloc] init];
    [self.navigationController pushViewController:controller animated:YES];

}
#pragma mark - get&set
#pragma mark - CellModel
-(NSArray *)cellModel{
    if (!_cellModel) {
        NSDictionary *d1 = @{
                             @"title":@"我的收藏",
                             @"icon":@"wujiaoxing",
                             @"ViewController":[MyCollectionViewController class]
                            };
        NSDictionary *d2 = @{
                             @"title":@"意见反馈",
                             @"icon":@"yijianfankui",
                             @"ViewController":[FeedbackViewController class]
                            };
        NSDictionary *d3 = @{
                             @"title":@"关于我们",
                             @"icon":@"guanyuwomen",
                             @"ViewController":[AboutUsViewController class]
                            };
        

        _cellModel = @[
                       @[d1],
                       @[d2,d3]
                       ];
    }
    return _cellModel;
}
@end
